package edu.xpu.compute.recommend.repository.meta;

import java.util.List;

import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.EntityGraph.EntityGraphType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import edu.xpu.compute.recommend.entity.meta.SysUserFaculty;

@Repository
public interface SysUserFacultyRepository extends JpaRepository<SysUserFaculty, Long>
		, JpaSpecificationExecutor<SysUserFaculty>{

	@Query(value="FROM SysUserFaculty s WHERE s.id = ?1")
	@EntityGraph(value="SysUserFaculty.majors", type=EntityGraphType.FETCH)
	public SysUserFaculty findByIdWithMajors(Long id);
	
	@Query(value="FROM SysUserFaculty s")
	@EntityGraph(value="SysUserFaculty.majors", type=EntityGraphType.FETCH)
	public List<SysUserFaculty> findAllWithMajors();
	
}
